import store from '@/store'

/**
 * 判断用户是否具有本权限
 * @param permission
 * @returns {boolean}
 */
export function hasPermission(permission) {
  let allowedPermissionStr = store.state.currentUser.permission.buttonList.join();
  if (allowedPermissionStr.indexOf(permission) > -1) {
    return true;
  } else {
    return false;
  }
}

/**
 * 判断用户名是否能够审核评论
 * @param authorName
 * @returns {boolean}
 */
export function ifUserCanCheckComment(authorName) {
  let allowCheckCommentUserStr = store.state.allowCheckCommentUser.join();
  if (allowCheckCommentUserStr.indexOf(authorName) > -1) {
    return true;
  } else {
    return false;
  }
}